package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the delete raw materials  from DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageDeleteRaw {
	private ConnectionToClient client ;
	private String[] str; 
/**
 * Constructor of this class 
 * @param str
 * @param client
 */
	public MessageDeleteRaw(String[] str, ConnectionToClient client){
		
		this.client= client ;
		this.str= str; 	
	}
	/**
	 * This method delete raw materials from DB
	 * @throws SQLException
	 * @throws IOException
	 */
public void DeleteRaw() throws SQLException, IOException{
		
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("DELETE FROM db.rawmaterial where name='"+str[1]+"';");
		ps.executeUpdate();
		ps.close();
		
		client.sendToClient("RawDelete");
		
	
	}

}
